var t = getApp();

Page({
    data: {
        language: "",
        current: 0,
        status: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        dividendData: "",
        dividenList: []
    },
    onLoad: function(t) {
        this.getDividend("");
    },
    getDividend: function(a) {
        var s = this, e = t.getNetAddresss("plugin.room.frontend.anchor.dividend");
        t._postNetWork({
            url: e,
            showToastIn: !1,
            data: {
                status: a,
                page: 1
            },
            success: function(t) {
                var a = t.data;
                1 == a.result ? s.setData({
                    dividendData: a.data.data,
                    dividenList: a.data.data.bonus,
                    total_page: a.data.last_page
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getMoreData: function() {
        var a = this, s = t.getNetAddresss("plugin.room.frontend.anchor.dividend");
        this.data.page != this.data.total_page && (this.data.page >= this.data.total_page ? this.setData({
            isLoadMore: !1
        }) : (this.setData({
            page: this.data.page + 1
        }), t._getNetWork({
            url: s,
            data: {
                status: this.data.status,
                page: this.data.page
            },
            success: function(t) {
                var s = t.data;
                1 == s.result ? a.setData({
                    cupconList: a.data.dividenList.concat(s.data.data.bonus)
                }) : a.setData({
                    page: a.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(t) {
                console.log(t);
            }
        })));
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onShareAppMessage: function() {},
    swichTabTItem: function(t) {
        var a = t.detail.index;
        this.setData({
            current: a
        }), 0 == a ? this.setData({
            status: ""
        }) : 1 == a ? this.setData({
            status: 0
        }) : 2 == a ? this.setData({
            status: 1
        }) : 3 == a && this.setData({
            status: -1
        }), this.setData({
            isLoadMore: !0,
            page: 1,
            total_page: 0
        }), this.getDividend(this.data.status);
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    }
});